package com.lemon.ui.codemaker.namecover;

public class NameCover {

	public static String autoCoverName(String name) {
		char[] tmp1 = name.toCharArray();
		StringBuffer sb = new StringBuffer();
		int j = -2;
		boolean covered;
		for (int i = 0; i < tmp1.length; i++) {
			char c = tmp1[i];
			covered = false;
			if(j == (i-1)) {
				c = Character.toUpperCase(c);
				covered = true;
			}
			if(c == '_') {
				j = i;
				continue;
			}
			if(Character.isUpperCase(c)&&!covered) {
				sb.append("_");
				c = Character.toLowerCase(c);
				covered = true;
			}
			sb.append(c);
		}
		return sb.toString();
	}
}
